#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    _login_dialog = new loginDialog();
    setCentralWidget(_login_dialog);  //设置loginDialog到central visit(主界面)里
    _login_dialog->show();

    //创建和注册消息连接
    connect(_login_dialog, &loginDialog::switchRegister, this, &MainWindow::SlotSwitchReg); //
    _register_dialog = new RegisterDialog();

}

MainWindow::~MainWindow()
{
    delete ui;
    if(_login_dialog){
        delete _login_dialog;
        _login_dialog = nullptr;
    }

    if(_register_dialog){
        delete _register_dialog;
        _register_dialog = nullptr;
    }
}

void MainWindow::SlotSwitchReg()
{
    setCentralWidget(_register_dialog);
    _login_dialog->hide();
    _register_dialog->show();

}

